package com.wh1200.xmlless.test.model

import com.wh1200.mybatis.xmlless.annotations.FeignProperty
import com.wh1200.mybatis.xmlless.annotations.JoinObject
import com.wh1200.mybatis.xmlless.annotations.JsonMappingProperty
import com.wh1200.mybatis.xmlless.annotations.SelectedProperties
import com.baomidou.mybatisplus.annotation.TableLogic
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.Table

/**
 *
 * @author 吴昊
 * @date 2021/3/30 10:24 下午
 * @since 3.5.1
 * @version 1.0
 */
@Entity
@Table(name = "t_role")
data class Role(
  @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @FeignProperty(
        targetEntity = com.wh1200.xmlless.test.model.User::class,
        joinOnTargetProperty = "roleIds",
        alias = "user"
    )
    var id: Int? = null,
  var name: String = "",
  @JsonMappingProperty
    var deps: List<Int> = listOf(),
  @JoinObject(
        joinOnThisProperty = "deps"
    )
    @SelectedProperties(["id", "name"])
    var depList: MutableList<com.wh1200.xmlless.test.model.Department> = arrayListOf(),
  @TableLogic(value = "0", delval = "2")
    var delFlag: String = "0"
) {

    /** 菜单组  */
    @JsonMappingProperty
    var menuIds: List<Long>? = null

}
